/**
 * 生成随机字符串(可指定长度)
 * @param len
 * @returns {string}
 */
function randomString(len: number = 4): string {
  len = len || 8;
  // tslint:disable-next-line: prefer-const
  let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
  /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
  const maxPos = $chars.length;
  let pwd = '';
  for (let i = 0; i < len; i++) {
    pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
  }
  return pwd;
}

export default randomString
